package common.util
{
	import flash.geom.Point;
	
	import mx.core.UIComponent;

	public class ComponentPositionUtil
	{
		public function ComponentPositionUtil()
		{
		}
		
		/**
		 * 获取父子组件之间的相对位置
		 */
		public static function getComponentPositionInParent(child:UIComponent,parent:UIComponent):Point{
			var parentPoint:Point = localToGlobal(parent);
			var childPoint:Point = localToGlobal(child);
			var resultPoint = new Point(childPoint.x-parentPoint.x,childPoint.y-parentPoint.y);
			return resultPoint;
		}
		
		/**
		 * 获取组件全局位置
		 */
		public static function localToGlobal(uiComponent:UIComponent):Point{
			var point:Point = new Point();
			point = uiComponent.localToGlobal(point);
			return point;
		}
	}
}